package com.bensoft.minesweeper;

import com.bensoft.minesweeper.gui.CheatWindow;
import com.bensoft.minesweeper.gui.MinesweeperFrame;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

/**
 *
 * @author Ben Wolsieffer
 */
public final class ApplicationController {

    private static MinesweeperFrame minesweeperFrame;
    private static GameManager gameManager;
    private static CheatWindow cheatWindow;

    /**
     * Get the main frame of the application
     *
     * @return the main frame
     */
    public static MinesweeperFrame getMinesweeperFrame() {
        return minesweeperFrame;
    }

    public static GameManager getGameManager() {
        return gameManager;
    }

    public static void setCheatEnabled(boolean enabled) {
        if (cheatWindow == null) {
            cheatWindow = new CheatWindow();
        }
        cheatWindow.setVisible(enabled);
    }

    public static void setCheatWhite(boolean white) {
        if (cheatWindow != null) {
            cheatWindow.setWhite(white);
        }
    }

    private ApplicationController() {
    }

    public static void main(String[] args) {
        try {
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
        }
        gameManager = new GameManager();
        minesweeperFrame = new MinesweeperFrame();
    }
}
